package com.zixuan.controller;

import com.zixuan.common.Result;
import com.zixuan.entity.EmployeeEntity;
import com.zixuan.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("sys/employee")

public class EmployeeController {
    @Autowired
    EmployeeService employeeService;
    /**
     * 添加员工
     */
    @PostMapping("addEmployee")
    public Result addEmployee(@RequestBody EmployeeEntity employee){
        return employeeService.addEmployee(employee);
    }

    /**
     * 删除员工信息
     */
    @DeleteMapping("/delEmployee/{id}")
    public Result delEmployeeById(@PathVariable("id") String id){
        return  employeeService.delEmployeeById(id);
    }


    /**
     * 批量删除员工信息
     */
    @PostMapping("/delEmployeeByIds")
    public Result delEmployeeById(@RequestBody String[] ids){
        return  employeeService.delEmployeeById(ids);
    }

    /**
     * 得到员工信息
     */
    @GetMapping("/getEmployeeBy/{id}")
    public Result getEmployeeBy(@PathVariable("id") String id){
        return employeeService.getEmployeeBy(id);
    }
    /**
     * 修改员工信息
     */

    @PutMapping("/putEmployee")
    public Result putEmployee(@RequestBody EmployeeEntity employeeEntity){
        return employeeService.putEmployee(employeeEntity);
    }

    /**
     * 得到所有员工的数据(分页)
     * 外加模糊查询
     */
    @GetMapping("/findAllEmployee/{start}/{end}")
    public Result findAllEmployee(@PathVariable("start") Integer start,@PathVariable("end") Integer end){
        return employeeService.findAllEmployee(start,end);
    }
}
